package org.example.edup;

import org.example.entity.user;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class helloword {
    public helloword(){
        System.out.println("我是初始化之后就会默认调用的构造方法");
    }
public void add(){
    System.out.println("方法");

}
//单例输出，只输出最后一个
    public List<user> get(ApplicationContext app){
        List<user> list=new ArrayList<>();
        /********** Begin **********/
        user user = (user) app.getBean("user");
        user user2 = (user) app.getBean("user");
        user.setName("张三丰");
        user2.setName("张无忌");
        list.add(user);
        list.add(user2);
        /********** End **********/
        return list;
    }
    //多例,输出全部
    public List<user> geta(ApplicationContext app){
        List<user> list=new ArrayList<>();
        /********** Begin **********/
        user user = (user) app.getBean("user2");
        user user2 = (user) app.getBean("user2");
        user.setName("张三丰");
        user2.setName("张无忌");
        list.add(user);
        list.add(user2);
        /********** End **********/
        return list;
    }
}
